import { ref, watch } from "vue";
import axios from "axios";

function userList() {
  const selectValue = ref("zdjy");
  const datalist = ref([]);
  watch(
    selectValue,
    async (value) => {
      const res = await axios.get(
        `http://localhost:3000/users?author=${value}`
      );
      console.log(res.data);
      datalist.value = res.data;
    },
    { immediate: true }
  );

  return{
    selectValue,
    datalist
  }
}

export default userList;

